﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace Deeper.Controls
{
	public static class HyControlHelper
	{
		/// <summary>
		/// 生成弹出控件顶部
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="Title"></param>
		/// <param name="Icon"></param>
		public static void RenderTop(this HtmlTextWriter writer, string Title, string Icon)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Class, "PopWindow");
			writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
			writer.RenderBeginTag(HtmlTextWriterTag.Table); ///table
			writer.RenderBeginTag(HtmlTextWriterTag.Tr); //第一行

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_leftTop");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第一行左
			writer.RenderEndTag();

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_centerTop");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第一行中间
			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_TopTitle");
			writer.RenderBeginTag(HtmlTextWriterTag.Div);
			writer.AddAttribute(HtmlTextWriterAttribute.Src, Icon); //输出图标
			writer.RenderBeginTag(HtmlTextWriterTag.Img);
			writer.RenderEndTag();
			writer.Write(Title); //输出标题
			writer.RenderEndTag();
			writer.RenderEndTag();

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_rightTop");
			writer.RenderBeginTag(HtmlTextWriterTag.Td);//第一行右侧
			writer.RenderEndTag();

			writer.RenderEndTag();//第一行结束

			writer.RenderBeginTag(HtmlTextWriterTag.Tr); //第二行

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_leftCenter");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第二行左
			writer.RenderEndTag();

			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第二行中
			writer.AddAttribute(HtmlTextWriterAttribute.Class, "contexCenter");
			writer.RenderBeginTag(HtmlTextWriterTag.Div);//输出一个控制位置的div
		}

		/// <summary>
		/// 生成弹出控件底部
		/// </summary>
		/// <param name="writer"></param>
		public static void RenderBottom(this HtmlTextWriter writer)
		{
			writer.RenderEndTag(); //第二行中间的div结束
			writer.RenderEndTag(); //第二行中间结束

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_rightCenter");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第二行右
			writer.RenderEndTag();

			writer.RenderEndTag(); //第二行结束

			writer.RenderBeginTag(HtmlTextWriterTag.Tr); //第三行

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_leftBottom");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第3行左
			writer.RenderEndTag();

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_centerBottom");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第3行中
			writer.RenderEndTag();

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "dialog_rightBottom");
			writer.RenderBeginTag(HtmlTextWriterTag.Td); //第3行右
			writer.RenderEndTag();

			writer.RenderEndTag();//第三行结束

			writer.RenderEndTag();//table结束

			writer.AddAttribute(HtmlTextWriterAttribute.Class, "overdiv"); //输出遮蔽层
			writer.RenderBeginTag(HtmlTextWriterTag.Div);
			writer.RenderEndTag();
		}


		/// <summary>
		/// 生成链接
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="eventRef"></param>
		/// <param name="Text"></param>
		public static void MakeHypeLink(this HtmlTextWriter writer, string cls, string eventRef, string Text)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Class, cls);
			writer.AddAttribute(HtmlTextWriterAttribute.Onclick, eventRef);
			writer.RenderBeginTag(HtmlTextWriterTag.A);
			writer.Write(Text);
			writer.RenderEndTag();
		}

		public static void MakeButton(this HtmlTextWriter writer, string cls, string eventRef, string Text)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Class, cls);
			writer.AddAttribute(HtmlTextWriterAttribute.Onclick, eventRef);
			//writer.AddAttribute(HtmlTextWriterAttribute.Value, value);
			writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
			writer.AddAttribute(HtmlTextWriterAttribute.Value, Text);
			writer.RenderBeginTag(HtmlTextWriterTag.Input);
			//writer.Write(Text);
			writer.RenderEndTag();
		}
	}

}
